package org.computate.guice;

import org.computate.controller.filter.ComputateFormFilter;
import org.computate.controller.filter.ComputateItemFilter;
import org.computate.controller.filter.Filter_page;
import org.computate.controller.filter.JsonItemFilter;
import org.computate.controller.filter.UserFilter;
import org.computate.controller.filter.item.Upload.FilterUploadProcessPhoto;
import org.sitemesh.config.ConfigurableSiteMeshFilter;

import com.cj.trim.trimFilter;
import com.google.inject.Singleton;
import com.google.inject.servlet.ServletModule;


public class GuiceServletModule extends ServletModule {
	
	@Override
	protected void configureServlets() {
		
		bind(ConfigurableSiteMeshFilter.class).in(Singleton.class);
		bind(trimFilter.class).in(Singleton.class);
		
		filter("/page/*").through(trimFilter.class);
		filter("/page/*").through(ConfigurableSiteMeshFilter.class);
		
		filter("/fragment/*").through(ConfigurableSiteMeshFilter.class);
		filter("/page/*").through(UserFilter.class);
		filter("/page/").through(Filter_page.class);
		serve("/json/item/*").with(JsonItemFilter.class);
		filter("/page/item/Upload/UploadProcessPhoto.jsp").through(FilterUploadProcessPhoto.class);
		
		filter("/page/form/*").through(ComputateFormFilter.class);
		serve("/download/form/*").with(ComputateFormFilter.class);
		filter("/page/item/*").through(ComputateItemFilter.class);
	}
}
